package com.google.gson

import org.json.JSONArray
import org.json.JSONObject
import org.junit.Assert
import org.junit.Test
import java.io.StringWriter

class GsonTest {
    @Test
    fun toJsonTest() {
//        val list = arrayListOf(Annotation("aaa"), Annotation("bbb"))
        val list = JsonArray()
        list.add(JsonObject().apply {
            addProperty("id", "aaa")
        })
        list.add(JsonObject().apply {
            addProperty("id", "bbb")
        })
        val writer = StringWriter()
        Gson().toJson(list, writer)
//        list(writer)
        val content = writer.toString()
        Assert.assertEquals("[{\"id\":\"aaa\"},{\"id\":\"bbb\"}]", content)
    }
}

class Annotation(var id: String) {

}
